package cn.sumpu.app.guoguojie.dao.impl;


import org.mybatis.spring.support.SqlSessionDaoSupport;

import cn.sumpu.app.guoguojie.dao.AppActivityRegisterDao;
import cn.sumpu.app.guoguojie.domain.AppActivity;
import cn.sumpu.app.guoguojie.domain.AppActivityRegister;
import cn.sumpu.app.guoguojie.exception.AppBusinessException;

public class AppActivityRegisterDaoImpl extends SqlSessionDaoSupport implements AppActivityRegisterDao{

	@Override
	public void insert(AppActivityRegister appActivityRegister) throws AppBusinessException {
		try {
			getSqlSession().insert(
					"cn.sumpu.app.guoguojie.persistence.AppActivityRegisterMapper.insert",
					appActivityRegister);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("Write database failure.", e);
			}
			throw new AppBusinessException("Write database failure.", e);
		}
	}

	@Override
	public void update(AppActivityRegister appActivityRegister) throws AppBusinessException {
		try {
			getSqlSession().update(
					"cn.sumpu.app.guoguojie.persistence.AppActivityRegisterMapper.update",
					appActivityRegister);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("update appActivity failure.", e);
			}
			throw new AppBusinessException("update appActivity failure.", e);
		}
		
	}

	@Override
	public AppActivity getAppActivityRegisterById(String identifier)
			throws AppBusinessException {
		try {
			return (AppActivity) getSqlSession()
					.selectOne(
							"cn.sumpu.app.guoguojie.persistence.AppActivityRegisterMapper.getAppActivityRegisterById",
							identifier);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("query failure.", e);
			}
			throw new AppBusinessException("query failure.", e);
		}
	}

	@Override
	public void deleteById(String identifier) throws AppBusinessException {
		try {
			getSqlSession()
					.delete("cn.sumpu.app.guoguojie.persistence.AppActivityRegisterMapper.deleteById",
							identifier);
		} catch (Exception e) {
			if (logger.isErrorEnabled()) {
				logger.error("delete failure.", e);
			}
			throw new AppBusinessException("delete failure.", e);
		}

		
	}

}
